package com.mlc.core.serviceImpl;

import com.mlc.data.entity.Albums;
import com.mlc.data.dao.AlbumsDao;
import com.mlc.core.service.AlbumsService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Optional;

/**
 * @author FireWang
 * @date 2022/03/14 02:46:46
 */
@Service
@AllArgsConstructor
@Transactional
public class AlbumsServiceImpl implements AlbumsService {
    private AlbumsDao albumsDao;

    @Override
    public List<Albums> getAll() {
        return albumsDao.findAll();
    }

    @Override
    public Albums getById(Integer id) {
        Optional<Albums> albums = albumsDao.findById(id);
        return albums.get();
    }

    @Override
    public void insert(Albums albums) {
        albumsDao.save(albums);
    }

    @Override
    public void update(Albums albums) {
        albumsDao.save(albums);
    }

    @Override
    public void deleteById(Integer id) {
        albumsDao.deleteById(id);
    }
}